$(function () {
    $('#fkhzjb_grid').datagrid({
        url: $.webPath() + "/report/fkhzjb/fkhzjbList",
        toolbar: "#toolbar_fkhzjb",
        fitColumns: true,
        checkOnSelect: false,
        selectOnCheck: false,
        singleSelect: true,
        pagination: true,
        pageNumber: 1,
        fit: true,
        striped: true,
        columns: [
            [
                {field: 'khid', hidden: true},
                {field: 'yysqc', title: '运营商', align: 'center', width: 100},
                {field: 'khqc', title: '代理客户', align: 'center', width: 100},
                {field: 'khh', title: '开户行', align: 'center', width: 60},
                {
                    field: 'czje', title: '充值金额(元)', align: 'center', width: 40,
                    formatter: function (value, row) {
                        var val = formatJe2(value, ",");
                        if (val)
                            return "<a href='javascript:void(0);' style='color: red' onclick='czjeDetail(" + row.khid + ")' >" + val + "</a>"
                        else
                            return val;
                    }
                },
                {
                    field: 'zjye', title: '资金余额(元)', align: 'center', width: 40,
                    formatter: function (value, row) {
                        var val = formatJe2(value, ",");
                        //if (val)
                        //    return "<a href='javascript:void(0);' style='color: green' onclick='zjyeDetail(" + row.khid + ")' >" + val + "</a>"
                        //else
                            return val;
                    }
                },
                {
                    field: 'hk', title: '货款(元)', align: 'center', width: 40,
                    formatter: function (value, row) {
                        var val = formatJe2(value, ",");
                        if (val)
                            return "<a href='javascript:void(0);' style='color: red' onclick='hkDetail(" + row.khid + ",120591)' >" + val + "</a>"
                        else
                            return val;
                    }
                },
                {
                    field: 'hkye', title: '货款余额(元)', align: 'center', width: 40,
                    formatter: function (value, row) {
                        var val = formatJe2(value, ",");
                        //if (val)
                        //    return "<a href='javascript:void(0);' style='color: red' onclick='hkDetail(" + row.khid + ",120591)' >" + val + "</a>"
                        //else
                            return val;
                    }
                },
                {
                    field: 'htbzj', title: '合同保证金(元)', align: 'center', width: 45,
                    formatter: function (value, row) {
                        var val = formatJe2(value, ",");
                        if (val)
                            return "<a href='javascript:void(0);' style='color: red' onclick='htbzjDetail(" + row.khid + ",121191)' >" + val + "</a>"
                        else
                            return val;
                    }
                },
                {
                    field: 'htbzjye', title: '合同保证金余额(元)', align: 'center', width: 55,
                    formatter: function (value, row) {
                        var val = formatJe2(value, ",");
                        //if (val)
                        //    return "<a href='javascript:void(0);' style='color: green' onclick='htbzjDetail(" + row.khid + ",121191)' >" + val + "</a>"
                        //else
                            return val;
                    }
                },
                {
                    field: 'syje', title: '使用金额(元)', align: 'center', width: 40,
                    formatter: function (value, row) {
                        var val = formatJe2(row.czje - row.zjye, ",");
                        //if (val)
                        //    return "<a href='javascript:void(0);' style='color: red' onclick='zjyeDetail(" + row.khid + ")' >" + val + "</a>"
                        //else
                            return val;
                    }
                }
            ]
        ]
    });

    $("#btn_fkhzjb_search").click(function () {
        fkhzjb_search();
    });

});

function fkhzjb_search() {
    var gsMc = $('#fkhzjb_gsMc').val();
    var khMc = $('#fkhzjb_khMc').val();
    $('#fkhzjb_grid').datagrid('load',
        {
            gsMc: gsMc,
            khMc: khMc
        }
    );
}
// 充值金额明细
function czjeDetail(khid) {
    $.window({
        title: '充值金额明细',
        iconCls: 'icon-tip',
        url: $.webPath() + "/report/fkhzjb/fkhzjbdetail?khId=" + khid,
        width: 1050,
        height: 500,
        modal: true,
        isMax: false
    })
}
// 货款明细
function hkDetail(khid, kxsy) {
    $.window({
        title: '货款明细',
        iconCls: 'icon-tip',
        url: $.webPath() + "/report/fkhzjb/fkhzjbdetail?khId=" + khid + "&kxsy=" + kxsy,
        width: 1050,
        height: 500,
        modal: true,
        isMax: false
    })
}
//合同保证金明细
function htbzjDetail(khid, kxsy) {
    $.window({
        title: '合同保证金明细',
        iconCls: 'icon-tip',
        url: $.webPath() + "/report/fkhzjb/fkhzjbdetail?khId=" + khid + "&kxsy=" + kxsy,
        width: 1050,
        height: 500,
        modal: true,
        isMax: false
    })
}
// 使用余额明细
function zjyeDetail(khid) {
    $.window({
        title: '使用余额明细',
        iconCls: 'icon-tip',
        url: $.webPath() + "/report/fkhzjb/fkhzjbdetail?khId=" + khid,
        width: 1050,
        height: 500,
        modal: true,
        isMax: false
    })
}
